<?php
namespace app\common\traits;
use think\Session;
use app\common\tool\UserTool;
trait ControllerTrait{
	private $__needLogin=true;
   // public $test="ssfdff";
   final public function _initialize(){
   	  $this->userTool=UserTool::instance((array)Session::get('current_user'));
   	  //个人
      method_exists($this,'beforeRun')&&$this->beforeRun();
   	  //框架
      method_exists($this,'beforeExec')&&$this->beforeExec();

      // //判断是否需要登录
      // if($this->__needLogin&&!$this->userTool->getId()){
      //      $this->lognException();  
      // }
      // //权限检测
      // if(method_exists($this,'access')&&$this->access()===false){
      // 	  $this->accessException();
      // }
   }
   //不要登录验证时调用
   public function unNeedLogin(){
   	  $this->__needLogin=false;
   }
}